package com.xue.springboot001.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class RequestController {

    @GetMapping("/goto")
    public String hello(HttpServletRequest request){
        request.setAttribute("msg","成功了...");
        request.setAttribute("code","200");
        return "forward:/success";
    }

    @GetMapping("/success")
    @ResponseBody
    public Map<String,Object> success(@RequestAttribute("msg") String msg,
                                      @RequestAttribute("code") String code,
                                      HttpServletRequest request){
        Object msg1 = request.getAttribute("msg");
        Map<String,Object> map = new HashMap<>();
        map.put("annotation",msg);
        map.put("request",msg1);
        return map;
    }

}
